package com.sskj.award.ui.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.award.R;
import com.sskj.award.R2;
import com.sskj.award.bean.AirDropBean;
import com.sskj.award.presenter.DetailsAssetsFragmentPresenter;
import com.sskj.common.util.ClickUtil;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.adapter.BaseAdapter;
import com.sskj.lib.adapter.ViewHolder;
import com.sskj.lib.base.BaseFragment;
import com.sskj.lib.util.NumberUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @ClassName: DetailsAssetsFragment
 * @Description: java类作用描述:资产明细fragment
 * @Author: yuanlin
 * @Date: 2019/7/12 15:45
 */
@Route(path = RConfig.SUPER_SUPER_DETAILS_ASSETS)
public class DetailsAssetsFragment extends BaseFragment<DetailsAssetsFragmentPresenter> {


    @BindView(R2.id.tvShowType)
    TextView tvShowType;
    @BindView(R2.id.tvShowBills)
    TextView tvShowBills;
    @BindView(R2.id.tvShowCollectionOrCap)
    TextView tvShowCollectionOrCap;
    @BindView(R2.id.tvShowAccumulatedRewards)
    TextView tvShowAccumulatedRewards;
    @BindView(R2.id.tvShowFrequencyLimit)
    TextView tvShowFrequencyLimit;
    @BindView(R2.id.tvShowFrozenAmount)
    TextView tvShowFrozenAmount;
    @BindView(R2.id.tvShowIncentiveQuota)
    TextView tvShowIncentiveQuota;
    @BindView(R2.id.tvCNBShowType)
    TextView tvCNBShowType;
    @BindView(R2.id.tvCNBShowBills)
    TextView tvCNBShowBills;
    @BindView(R2.id.tvCNBShowCollectionOrCap)
    TextView tvCNBShowCollectionOrCap;
    @BindView(R2.id.tvCNBShowAccumulatedRewards)
    TextView tvCNBShowAccumulatedRewards;
    @BindView(R2.id.tvCNBShowFrequencyLimit)
    TextView tvCNBShowFrequencyLimit;
    @BindView(R2.id.tvCNBShowFrozenAmount)
    TextView tvCNBShowFrozenAmount;
    @BindView(R2.id.tvCNBShowIncentiveQuota)
    TextView tvCNBShowIncentiveQuota;
    @BindView(R2.id.tvLNCShowType)
    TextView tvLNCShowType;
    @BindView(R2.id.tvLNCShowBills)
    TextView tvLNCShowBills;
    @BindView(R2.id.tvLNCShowCollectionOrCap)
    TextView tvLNCShowCollectionOrCap;
    @BindView(R2.id.tvLNCShowAccumulatedRewards)
    TextView tvLNCShowAccumulatedRewards;
    @BindView(R2.id.tvLNCShowFrequencyLimit)
    TextView tvLNCShowFrequencyLimit;
    @BindView(R2.id.tvLNCShowFrozenAmount)
    TextView tvLNCShowFrozenAmount;
    @BindView(R2.id.tvLNCShowIncentiveQuota)
    TextView tvLNCShowIncentiveQuota;

    @Override
    protected int getLayoutId() {
        return R.layout.super_layout_fragment_details_assets;
    }

    @Override
    protected DetailsAssetsFragmentPresenter getPresenter() {
        return new DetailsAssetsFragmentPresenter();
    }

    @Override
    protected void initView() {
        super.initView();
        mPresenter.getAirData();

        ClickUtil.click(300, tvShowBills, () -> {
            ARouter.getInstance().build(RConfig.SUPER_SUPER_AIR_DROP_BILL).withString(Constans.TYPE,"SOP").navigation();
        });
        ClickUtil.click(300, tvCNBShowBills, () -> {
            ARouter.getInstance().build(RConfig.SUPER_SUPER_AIR_DROP_BILL).withString(Constans.TYPE,"CNB").navigation();
        });
        ClickUtil.click(300, tvLNCShowBills, () -> {
            ARouter.getInstance().build(RConfig.SUPER_SUPER_AIR_DROP_BILL).withString(Constans.TYPE,"LAC").navigation();
        });

    }

    @SuppressLint("SetTextI18n")
    public void getAirDataSuccess(AirDropBean data) {
        if (data.getSOP() == null) {
            return;
        }
        AirDropBean.SOPBean sop = data.getSOP();


        tvShowCollectionOrCap.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(sop.getAlready_get_award(),6))) + "/" + NumberUtil.keepNoZero(NumberUtil.keep(sop.getGet_award_day_max(),6)));
        tvShowAccumulatedRewards.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(sop.getTotal_get_award(),6)))+"USDT");
        tvShowFrequencyLimit.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(sop.getAlready_get_award(),6))) + "/" + NumberUtil.keepNoZero(NumberUtil.keep(sop.getGet_award_count(),6)));
        tvShowFrozenAmount.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(sop.getFrost_get_award(),6)))+"USDT");
        tvShowIncentiveQuota.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(sop.getGet_award_each_max(),6)))+"USDT");

        if (data.getCNB() == null) {
            return;
        }
        AirDropBean.CNBBean cnb = data.getCNB();
        tvCNBShowCollectionOrCap.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(cnb.getAlready_get_award(),6))) + "/" + NumberUtil.keepNoZero(NumberUtil.keep(cnb.getGet_award_day_max(),6)));
        tvCNBShowAccumulatedRewards.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(cnb.getTotal_get_award(),6)))+"USDT");
        tvCNBShowFrequencyLimit.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(cnb.getAlready_get_award(),6))) + "/" + NumberUtil.keepNoZero(NumberUtil.keep(cnb.getGet_award_count(),6)));
        tvCNBShowFrozenAmount.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(cnb.getFrost_get_award(),6)))+"USDT");
        tvCNBShowIncentiveQuota.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(cnb.getGet_award_each_max(),6)))+"USDT");
        if (data.getLAC() == null) {
            return;
        }
        AirDropBean.LACBean lac = data.getLAC();

        tvLNCShowCollectionOrCap.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(lac.getAlready_get_award(),6))) + "/" + NumberUtil.keepNoZero(NumberUtil.keep(lac.getGet_award_day_max(),6)));
        tvLNCShowAccumulatedRewards.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(lac.getTotal_get_award(),6)))+"USDT");
        tvLNCShowFrequencyLimit.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(lac.getAlready_get_award(),6))) + "/" + NumberUtil.keepNoZero(NumberUtil.keep(lac.getGet_award_count(),6)));
        tvLNCShowFrozenAmount.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(lac.getFrost_get_award(),6)))+"USDT");
        tvLNCShowIncentiveQuota.setText(NumberUtil.keepNoZero(NumberUtil.keepNoZero(NumberUtil.keep(lac.getGet_award_each_max(),6)))+"USDT");

    }
}
